#ifndef CSCOPE_H_INCLUDED
#define CSCOPE_H_INCLUDED

#include <wx/wxprec.h>

#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#include <wx/timer.h>
#include <cbplugin.h>
#include <queue>

class CscopeConfig;
class CscopeView;
class CscopeParserThread;
class CscopeProcess;

class CscopePlugin : public cbPlugin {
  public:
    CscopePlugin();
    virtual ~CscopePlugin();
    virtual int GetConfigurationPriority() const { return 50; }
    virtual int GetConfigurationGroup() const { return cgUnknown; }
    virtual cbConfigurationPanel* GetConfigurationPanel(wxWindow*) { return 0; }
    virtual cbConfigurationPanel* GetProjectConfigurationPanel(wxWindow*, cbProject*) { return 0; }
    virtual void BuildMenu(wxMenuBar*) {}
    virtual void BuildModuleMenu(const ModuleType type, wxMenu* menu, const FileTreeData* data = 0);
    virtual bool BuildToolBar(wxToolBar*) {return false;}
  protected:
    virtual void OnAttach();
    virtual void OnRelease(bool appShutDown);
  public:
    void OnProcessGeneratedOutputLine(const wxString &line);
  private:
    void MakeOutputPaneVisible();
    wxString GetWordAtCaret();
    void ClearOutputWindow();
    bool CreateListFile(wxString &list_file);
    void DoCscopeCommand(const wxString &cmd, const wxString &endMsg);
    void OnFind(wxCommandEvent &event);
    wxString GetCscopeBinaryName();
    void OnParserThreadEnded(wxCommandEvent &event);
    void OnParserThreadUpdateStatus(wxCommandEvent &e);
    void OnCscopeUI(wxUpdateUIEvent &event);
    void OnCscopeReturned(wxProcessEvent &event);
    void OnIdle(wxIdleEvent& event);
    wxString m_EndMsg;
    wxArrayString m_CscouptOutput;
    CscopeConfig *m_cfg;
    CscopeView *m_view;
    int m_ListPageIndex;
    CscopeProcess *m_pProcess;
    CscopeParserThread *m_thrd;
  private:
    DECLARE_EVENT_TABLE();
};

#endif
